# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=aiohttp
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=3.8.5
pkgrel=1
pkgdesc='HTTP client/server for asyncio (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
url="https://aiohttp.readthedocs.io/"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-attrs"
         "${MINGW_PACKAGE_PREFIX}-python-charset-normalizer"
         "${MINGW_PACKAGE_PREFIX}-python-multidict"
         "${MINGW_PACKAGE_PREFIX}-python-async-timeout"
         "${MINGW_PACKAGE_PREFIX}-python-yarl"
         "${MINGW_PACKAGE_PREFIX}-python-frozenlist"
         "${MINGW_PACKAGE_PREFIX}-python-aiosignal")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-wheel"
             "${MINGW_PACKAGE_PREFIX}-cc")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-freezegun"
"${MINGW_PACKAGE_PREFIX}-python-pytest-runner"
"${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
"${MINGW_PACKAGE_PREFIX}-python-pytest-forked"
"${MINGW_PACKAGE_PREFIX}-python-pytest-mock"
"${MINGW_PACKAGE_PREFIX}-python-pytest-timeout"
"${MINGW_PACKAGE_PREFIX}-python-pytest-xdist"
"${MINGW_PACKAGE_PREFIX}-python-trustme"
"${MINGW_PACKAGE_PREFIX}-python-async_generator"
"${MINGW_PACKAGE_PREFIX}-python-brotli")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-brotli: for Brotli transfer-encodings support")
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b9552ec52cc147dbf1944ac7ac98af7602e51ea2dcd076ed194ca3c0d1c7d0bc')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m pytest
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
